$(document).ready(function()
    {
        $.table_master = null;
        
        $.init_master = function()
        {
            $.ajax({
                url: base_url + 'br-03/bukti_transaksi/get_all',
                type: 'post',
                success : function(data)
                {
                    $.table_master = $('#bkk_bkb_table').dataTable({
                        "bJQueryUI": true,
                        "sPaginationType": "full_numbers",
                        "aaData": data.data,
                        "bDestroy": true,
                        "aoColumns":[
                                
                                    {'sTitle' : 'ID Bukti Transaksi', 'mDataProp' : 'ID_BUKTI_TRANSAKSI'},

                                    {'sTitle' : 'Nomer Transaksi', 'mDataProp' : 'NOMER_TRANSAKSI'},

                                    {'sTitle' : 'Tanggal Transaksi', 'mDataProp' : 'TGL_TRANSAKSI'},

                                    {'sTitle' : 'Keterangan', 'mDataProp' : 'KETERANGAN'},
                            ]
                    });
                },
                error: function(res)
                {
                    alert(res.responseText);
                },
                dataType: 'json'
            });
        }
        $.init_master();

   
        $('#bkk_bkb_dialog').dialog({
            title: 'Data Transaksi',
            width: '950px',
            autoOpen:false,
            modal:true,
            resizable:false
        });

        $.resultbkk_bkb = function(data)
        {
            if($('td:first', data).html() != 'No matching records found')
            {
                $("#BKK_BKB").val($('td:first', data).html());
                $("#NOMER_BKK_BKB").val($('td:eq(1)', data).html());
            }
        }

        $('#bkk_bkb_table tbody tr').live('click', function()
        {
            $.datatablebkk_bkbRowClicked(this);
        });

        $.datatablebkk_bkbRowClicked = function(that)
        {
            $.resultbkk_bkb(that);
            $('#bkk_bkb_dialog').dialog('close');
        }

        $('#BKK_BKB').click(function(){
            $('#bkk_bkb_dialog').dialog('open')
        });
    });